-
-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kickstart support drop for Python < 3.7 #499
Conversation
Step 1 of code clean-up: mechanically remove if-else branches that would never run in Python/PyPy >= 3.7. There's still some unused or redundant code, left for the next step to facilitate review. Note: all the remaining `sys.hexversion` tests were standardized to use numerical comparison and hexadecimal integer literals (e.g. `0x30b00a7` for version 3.11.0a7) as most of them already were.
There are a couple more that are no longer needed. |
Yes, the now obsolete |
I'd split your steps into two or three different PRs -- keep this one as (1 & 2), and create a new PR for (4). I'm not sure the best place for (3). I think we can get (1 & 2) into dill-0.3.6. Official end of support for 3.7 from python.org is 2023-06-27. So that means |
Agreed. Is there a way to create an empty draft PR? Or do I nead at least a stub change? |
@mmckerns I managed to open the PRs with empty commits. You can add the milestone to this one now. |
@mmckerns and @anivegesana: this is ready for review. |
I've reviewed all files except |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM. Thanks for all the hard (and tedious) work. Please address all of my comments and change requests. One thing to also watch out for in dill._dill
is cases where we want to always want to trap any exception, regardless if it looks like there's only a particular type that is possible (i.e. the exception is used more like a if/else). I noted a few cases that I couldn't remember fully what scope the exception block was intended to have.
Applied the requested corrections and then merged with master HEAD. All tests passing 100%. I'm feeling this is ready to go! |
You're welcome! 🙂 Applying one step at a time to all files sped up the process. Vim search and substitutions also helped a lot. But I'm pretty sure that reviewing for you was as much as tedious as editing for me...
In the end, except for the |
Some of this code is 15 years old. I feel like I should get into a time machine and tell younger me to document the exception blocks more. |
Side note: can you email me a list of the keywords you searched for in your removal of dead code? I'm making similar changes on the other UQF codes. |
Not many, really. What I remember is, for the conditional code:
I think you'll find most Python 2 stuff by looking for these (if the other packages use the same conventions). Perhaps look for case insensitive
I didn't check for everything in dill though. Also, maybe take a look at https://docs.python.org/3/howto/pyporting.html |
Thanks, that's similar to my list. I've also included |
@mmckerns: just pushed the merge commit with the trace PR. |
@mmckerns and @anivegesana, plus anyone interested: With the prospect of dill 0.3.6 release —it would be fun if it matched the lowest Python version supported, 3.7— in the near future, it is an opportunity to remove some cruft from the code base after the official support drop for Python 2 and Python < 3.7. Important: this is not a refactoring.
I propose to do so in discrete steps to facilitate review and minimize the chances of introducing bugs. The first steps should only remove code that Python/PyPy >= 3.7 will never run, with minimal code rewrite beyond necessary indentation changes and substitution of variables left as unconditional constants, after the other changes, by its literal values.
I plan to do each step in a separated commit, so that you guys can review the individual diffs and any unit test failure is easy to catch:
IS_PYPY2
), and convert the new unconditional constants left to literals.exec()
due to syntax limitations to common if-else code. Remove conditional imports. Removefrom __future__
imports._reverse_typemap
, to still allow unpickling of objects created with older combinations of python+dill versions. Unalias some types for internal usage, like BytesIO that is renamed to StringIO —it was a bit confusing the first time I met it. → moved to Support drop for Python < 3.7: step 3 — remove unused types and save_*() functions #504Neither all steps are strictly necessary, nor they need to be completed before the next release. If you have the time, it would be important to thoroughly review every change made (the more eyeballs, the better). Please feel completely free to make changes by committing directly here and to add or remove steps to the ones I'm suggesting.